class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        ListNode* guard = new ListNode;
        guard->next = head;
        ListNode* cur = guard;
        while (cur->next && cur->next->next)
        {
            ListNode* tmp1 = cur->next;
            ListNode* tmp2 = cur->next->next->next;
            cur->next = cur->next->next;
            cur->next->next = tmp1;
            tmp1->next = tmp2;
            cur = tmp1;
        }
        head = guard->next;
        delete guard;
        return head;
    }
};